import React, { useState, useEffect } from 'react'
import axios from 'axios'


export default props => {
  console.log( props )

  useState(() => {

    return undefined
  }, [])

  // 一个副作用做一件事、调用QQ音乐的接口
  useEffect(() => {
    let str = 'ct=24&qqmusic_ver=1298&new_json=1&remoteplace=txt.yqq.top&searchid=25697592547780876&t=0&aggr=1&cr=1&catZhida=1&lossless=0&flag_qc=0&p=1&n=10&w=%E5%91%A8%E6%9D%B0%E4%BC%A6&g_tk_new_20200303=264588153&g_tk=264588153&loginUin=1691732926&hostUin=0&format=json&inCharset=utf8&outCharset=utf-8&notice=0&platform=yqq.json&needNewCode=0'

    const params = {}
    str.split('&').map(item => {
      const arr = item.split('=')
      params[arr[0]] = arr[1]
    })
    params.w = '周杰伦'

    axios.get('http://localhost:8080/soso/fcgi-bin/client_search_cp', {
      params
    }).then(res => {
      console.log( res )
    })

    return undefined
  }, [])

  return (
    <div className='container'>
      <h3>MusicHooks 的 Hooks 写法</h3>
    </div>
  )
}